home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rwvector.lha / RWVector2.1 / cfront.patch.et++ next >
Text File  |  1989-08-18  |  7KB  |  288 lines

  1. This patch to cfront Version 1.2 came from the Et++ distribution.  I
  2. have found it useful for clearing up some of the more notorious cfront
  3. bugs.
  4.  
  5. diff -c src.orig/cfront.h src/cfront.h
  6. *** src.orig/cfront.h    Sat Apr 22 02:11:11 1989
  7. --- src/cfront.h    Sat Apr 22 02:09:29 1989
  8. ***************
  9. *** 100,105 ****
  10. --- 100,106 ----
  11.   extern int error_count;
  12.   extern bit debug;
  13.   extern int vtbl_opt;
  14. + extern int vtbl_opt2;
  15.   extern FILE* out_file;
  16.   extern FILE* in_file;
  17.   extern char scan_started;
  18. diff -c src.orig/expand.c src/expand.c
  19. *** src.orig/expand.c    Sat Apr 22 02:11:11 1989
  20. --- src/expand.c    Sat Apr 22 02:09:30 1989
  21. ***************
  22. *** 149,154 ****
  23. --- 149,155 ----
  24.       }
  25.   
  26.       if (expand_tbl) {    /* make expression */
  27. +         extern int functiondefinedinclass;
  28.           Pexpr ee;
  29.           static ret_seen = 0;
  30.   
  31. ***************
  32. *** 159,165 ****
  33.               for (n = tbl->get_mem(i=1); n; n=tbl->get_mem(++i)) {
  34.                   if (n->base!=NAME || n->tp==any_type) continue;
  35.                   if ( base == BLOCK && 
  36. !                    n->lex_level<((Pfct(expand_fn->tp)->memof)?3:2))
  37.                        continue;
  38.                   Pname nn = dcl_local(scope,n,expand_fn);
  39.                   nn->base = NAME;
  40. --- 160,166 ----
  41.               for (n = tbl->get_mem(i=1); n; n=tbl->get_mem(++i)) {
  42.                   if (n->base!=NAME || n->tp==any_type) continue;
  43.                   if ( base == BLOCK && 
  44. !                 ((n->lex_level < functiondefinedinclass) ? 3 : 2))
  45.                        continue;
  46.                   Pname nn = dcl_local(scope,n,expand_fn);
  47.                   nn->base = NAME;
  48. diff -c src.orig/lex.c src/lex.c
  49. *** src.orig/lex.c    Sat Apr 22 02:11:12 1989
  50. --- src/lex.c    Sat Apr 22 02:09:31 1989
  51. ***************
  52. *** 487,500 ****
  53. --- 487,530 ----
  54.       }
  55.   }
  56.   
  57. + char nextclassvtbl[40][40];
  58.   
  59.   void linecom()
  60.   // process a "line comment"
  61.   {
  62.       register c;
  63. +     static int ncvcnt= 0;
  64.   
  65.       for(;;)
  66.       switch (get(c)) {
  67. +     case '$':
  68. +         int i;
  69. +         if (!vtbl_opt2)
  70. +             break;
  71. +     restart:
  72. +         i= 0;
  73. +         for(;;)
  74. +             switch(get(c)) {
  75. +             case ',':
  76. +             nextclassvtbl[ncvcnt++][i]= 0;
  77. +             goto restart;
  78. +             case '\n':
  79. +             curloc.line++;
  80. +             Nline++;
  81. +             saved = lxtitle();
  82. +             case '$':
  83. +             goto out;
  84. +             case EOF:
  85. +             error("eof in comment");
  86. +             return;
  87. +             default:
  88. +             nextclassvtbl[ncvcnt][i++]= c;
  89. +             case ' ':
  90. +             break;
  91. +         }
  92. +     out:    nextclassvtbl[ncvcnt++][i]= 0;
  93. +         nextclassvtbl[ncvcnt][0]= 0;
  94. +         break;
  95.       case EOF:
  96.           error("eof in comment");
  97.           return;
  98. diff -c src.orig/main.c src/main.c
  99. *** src.orig/main.c    Sat Apr 22 02:11:12 1989
  100. --- src/main.c    Sat Apr 22 02:09:32 1989
  101. ***************
  102. *** 69,74 ****
  103. --- 69,75 ----
  104.               // 0 external and supposed to be defined elsewhere
  105.               // 1 external and defined
  106.   
  107. + int vtbl_opt2= 0;
  108.    simpl_init();
  109.    typ_init();
  110.    syn_init();
  111. ***************
  112. *** 89,95 ****
  113.           fprintf(stderr,"start time: %s", ctime(&start_time) );
  114.           fprintf(stderr,"stop time:  %s", ctime(&stop_time) );
  115.           fprintf(stderr,"real time delay %ld: %d lines per second\n",
  116. !             stop_time-start_time, Nline/(stop_time-start_time) );
  117.           fflush(stderr);
  118.       }
  119.       print_free();
  120. --- 90,98 ----
  121.           fprintf(stderr,"start time: %s", ctime(&start_time) );
  122.           fprintf(stderr,"stop time:  %s", ctime(&stop_time) );
  123.           fprintf(stderr,"real time delay %ld: %d lines per second\n",
  124. !             stop_time-start_time,
  125. !             stop_time-start_time > 0 ? Nline/(stop_time-start_time)
  126. !                          : Nline);
  127.           fflush(stderr);
  128.       }
  129.       print_free();
  130. ***************
  131. *** 403,408 ****
  132. --- 406,414 ----
  133.                       case '0':
  134.                       case '1': 
  135.                           vtbl_opt = *cp-'0';
  136. +                         break;
  137. +                     case '2':
  138. +                         vtbl_opt2= 1;
  139.                           break;
  140.                       default:
  141.                           fprintf(stderr,"bad +e option");
  142. diff -c src.orig/norm.c src/norm.c
  143. *** src.orig/norm.c    Sat Apr 22 02:11:12 1989
  144. --- src/norm.c    Sat Apr 22 02:09:33 1989
  145. ***************
  146. *** 1174,1179 ****
  147. --- 1174,1181 ----
  148.       bit v = 0;
  149.       register Ptype t = this;
  150.   
  151. +     if (t == 0)
  152. +         return 0;
  153.       eobj = 0;
  154.       cl_obj_vec = 0;
  155.   xx:
  156. diff -c src.orig/print.c src/print.c
  157. *** src.orig/print.c    Sat Apr 22 02:11:13 1989
  158. --- src/print.c    Sat Apr 22 02:43:50 1989
  159. ***************
  160. *** 964,969 ****
  161. --- 964,971 ----
  162.   
  163.   void classdef::dcl_print(Pname)
  164.   { 
  165. +     extern char nextclassvtbl[40][40];
  166. +     int vo;
  167.       Plist l;
  168.       TOK c = csu==CLASS ? STRUCT : csu;
  169.   
  170. ***************
  171. *** 1025,1032 ****
  172.                       }
  173.                   }
  174.               }
  175. !             switch (vtbl_opt) {
  176.               case -1:
  177.                   putstring("static ");
  178.               case 1:
  179. --- 1027,1043 ----
  180.                       }
  181.                   }
  182.               }
  183. !             if (vtbl_opt2) {
  184. !                 int ii;
  185. !                 vo= 0;
  186. !                 for (ii= 0; nextclassvtbl[ii][0]; ii++)
  187. !                 if (strcmp(string, nextclassvtbl[ii]) == 0) {
  188. !                     vo= 1;
  189. !                     break;
  190. !                 }
  191. !             } else
  192. !                 vo= vtbl_opt;
  193. !             switch (vo) {
  194.               case -1:
  195.                   putstring("static ");
  196.               case 1:
  197. diff -c src.orig/simpl.c src/simpl.c
  198. *** src.orig/simpl.c    Sat Apr 22 02:11:13 1989
  199. --- src/simpl.c    Sat Apr 22 02:09:35 1989
  200. ***************
  201. *** 920,925 ****
  202. --- 920,926 ----
  203.       return stail;
  204.   }
  205.   
  206. + int functiondefinedinclass= 0;
  207.   
  208.   void classdef::simpl()
  209.   {
  210. ***************
  211. *** 928,933 ****
  212. --- 929,935 ----
  213.       Pclass oc = in_class;
  214.   
  215.       in_class = this;
  216. +     functiondefinedinclass++;
  217.       for (m=memtbl->get_mem(i=1); m; m=memtbl->get_mem(++i) ) {
  218.           Pexpr i = m->n_initializer;
  219.           m->n_initializer = 0;
  220. ***************
  221. *** 934,939 ****
  222. --- 936,942 ----
  223.           m->simpl();
  224.           m->n_initializer = i;
  225.       }
  226. +     functiondefinedinclass--;
  227.       in_class = oc;
  228.   
  229.       for (Plist fl=friend_list; fl; fl=fl->l) {    /* simplify friends */
  230. ***************
  231. *** 1141,1147 ****
  232.               e1->tp = q->tp->deref();
  233.           }
  234.           else {                    // may be virtual: yuk
  235. !             Pfct f = Pfct(Pptr(q->tp)->typ);
  236.               if (f->f_this == 0) {
  237.                   if (f->memof == 0) error('i',"memof missing");
  238.                   Pname tt = new name("this");
  239. --- 1144,1153 ----
  240.               e1->tp = q->tp->deref();
  241.           }
  242.           else {                    // may be virtual: yuk
  243. !             Ptype pt = q->tp;
  244. !             while (pt->base == TYPE)
  245. !                 pt= Pbase(pt)->b_name->tp;
  246. !             Pfct f = Pfct(Pptr(pt)->typ);              
  247.               if (f->f_this == 0) {
  248.                   if (f->memof == 0) error('i',"memof missing");
  249.                   Pname tt = new name("this");
  250. diff -c src.orig/size.h src/size.h
  251. *** src.orig/size.h    Sat Apr 22 02:11:13 1989
  252. --- src/size.h    Sat Apr 22 02:09:36 1989
  253. ***************
  254. *** 120,126 ****
  255.   #define DF_SENSITIVE 0
  256.   #define DF_OPTIMIZED 1
  257.   #else
  258. ! #if sun | mc68k
  259.                   /* most M68K boxes */
  260.   #define DBI_IN_WORD 32
  261.   #define DBI_IN_BYTE 8
  262. --- 120,126 ----
  263.   #define DF_SENSITIVE 0
  264.   #define DF_OPTIMIZED 1
  265.   #else
  266. ! #if sun | mc68k | m68k
  267.                   /* most M68K boxes */
  268.   #define DBI_IN_WORD 32
  269.   #define DBI_IN_BYTE 8
  270. ***************
  271. *** 182,188 ****
  272.   #define DF_SENSITIVE 0
  273.   #define DF_OPTIMIZED 1
  274.   #else
  275. ! #if uts
  276.                   /* Amdahl running UTS */
  277.   #define DBI_IN_WORD 32
  278.   #define DBI_IN_BYTE 8
  279. --- 182,188 ----
  280.   #define DF_SENSITIVE 0
  281.   #define DF_OPTIMIZED 1
  282.   #else
  283. ! #if uts || mips
  284.                   /* Amdahl running UTS */
  285.   #define DBI_IN_WORD 32
  286.   #define DBI_IN_BYTE 8
  287.